<template>
  <h2>readonly 和 shallowReadonly</h2>
  <h3>state:{{ state2 }}</h3>
  <hr>
  <button @click="update">更新数据</button>
</template>

<script>
import { defineComponent,reactive,shallowReadonly } from "vue";
export default defineComponent({
  name: "App",
  setup() {
    const state = reactive({
      name: "小雨",
      age: 20,
      car: { name: "玛莎拉蒂", color: "yellow" },
    });
    // const state2 = readonly(state)
    const state2 = shallowReadonly(state)
    const update=()=>{
      // console.log(111);
      // state2.name += '==='
      state2.car.name +='==='
    }
    return {
      state2,
      update
    };
  },
});
</script>

<style lang="less" scoped>
</style>
